
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ?
        module.exports = factory() :
        typeof define === 'function' && define.amd ?
            define(factory) : (global = global || self, global.Store = factory());
}(this , function () {
    var Store = function ( options ) {
        this.state = {};
        this.init(this , options);
    };
    Store.prototype.init = function (vm , options) {
        //绑定state属性值，
        var state = options.state || {};
        for(var key in state){
            vm.state[key] = state[key];
        }
        // 绑定mutations方法
        var mutations = options.mutations || {};
        for(var fnKey in mutations){
            vm[fnKey] = mutations[fnKey];
        }
        //绑定$commit提交方法
        vm.$commit = function (fnName , value) {
            if(vm.hasOwnProperty(fnName) && vm[fnName] instanceof Function){
                vm[fnName](vm.state , value)
            }
        };
    };
    return Store;
}));
